import {Constant, BaseEcharts} from "@/echarts/BaseEcharts";
import dayjs from 'dayjs';

/**
 * 交付物提交情况
 */
export class DeliverChart extends BaseEcharts {

    constructor(dom) {
        super(dom);
        this.type = Constant.TYPE.PIE;
    }

    //****************饼状
    _configPieData(raw = []) {
        let data = [];
        for (let item of raw) {
            data.push({
                name: item.name,
                value: item.value
            });
        }
        return data
    }

    createPie(data) {
        this.option = {
            // title: {
            //     text: 'Referer of a Website',
            //     subtext: 'Fake Data',
            //     left: 'center'
            // },
            tooltip: {
                trigger: 'item'
            },
            legend: {
                orient: 'vertical',
                left: 'left'
                // top: "top"
            },
            series: [
                {
                    name: '交付物执行情况',
                    type: 'pie',
                    radius: ['40%', '80%'],
                    data: data,
                    emphasis: {
                        itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        this.myChart.setOption(this.option);
        // window.addEventListener("resize", function (ev) {
        //   this.myChart.resize();
        // });
    }

    changeChartType(type) {
        this.create(this.raw, type)
    }

}

